﻿@implements IDisposable
@inject IResizeListener listener
@page "/"

<h3>Height: <span title="browserHeight">@browser.Height</span></h3>
<h3>Width: <span title="browserWidth">@browser.Width</span></h3>
<h3>MQ: <span title="isSmallMedia">@IsSmallMedia</span></h3>

@code {

    BrowserWindowSize browser = new BrowserWindowSize();

    bool IsSmallMedia = false;


    protected override void OnAfterRender(bool firstRender)
    {
        if (firstRender)
        {
            listener.OnResized += WindowResizedA;
        }
    }

    void IDisposable.Dispose()
    {
        listener.OnResized -= WindowResizedA;
    }

    async void WindowResizedA(object _, BrowserWindowSize window)
    {
        browser = window;
        IsSmallMedia = await listener.MatchMedia(Breakpoints.XLargeUp);
        StateHasChanged();
    }


}